<?
/**
* Copyright (c) 2002-2007 BioWare Corp.
* http://www.bigdaddymonitor.org
*
* This file is part of the BigDaddy Monitoring
* program. It is free software distributed under
* the terms of the BSD License. It is ditributed
* in the hopes that it will be useful, but
* WITHOUT ANY WARRANTY; without event the implied
* warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE.
*
* The BSD License is available from:
* http://www.opensource.org/licenses/bsd-license.php
**/
//=============================================================//
//Query File for Server Control (BigDaddy v2)
//Duleepa Wijyawardhana, 15.03.2004
//=============================================================//

switch($_REQUEST["action"])
{
    case "addnewcategory":
        if ($_POST["catname"]!="")
        {
			$BigDaddyControl->SetServerCategory($_POST["catname"]);
			$redirectTo="page=ServerCategory";
        }
        break;
    case "editcategory":
        if ($_POST["catname"]!="" && $_POST["catID"]>0)
        {
			$BigDaddyControl->SetServerCategory($_POST["catname"],$_POST["catID"]);
            $redirectTo="page=ServerCategory";
        }
        break;
    case "deletecategory":
        if ($_REQUEST["catID"]>0)
        {
			$BigDaddyControl->RemoveServerCategory($_REQUEST["catID"]);
            $redirectTo="page=ServerCategory";
        }
        break;
    case "addserver":
        if ($_POST["hostname"]!="")
        {
			
			$aInfo["hostname"] = htmlspecialchars($_POST["hostname"]);
			$aInfo["iniID"] = $_POST["iniID"];
			$aInfo["mon_startlevel"] = $_POST["mon_startlevel"];
			$aInfo["mon_endlevel"] = $_POST["mon_endlevel"];
			$aInfo["mon_internalreport"] = $_POST["mon_internalreport"];
			$aInfo["mon_externalreport"] = $_POST["mon_externalreport"];
			$aInfo["os_type"] = $_POST["os_type"];
			$aInfo["notes"] = htmlspecialchars($_POST["notes"]);
			$aInfo["cat"] = $_POST["cat"];
			
			$insertID = $BigDaddyControl->SetServer($aInfo);
            
			$redirectTo="page=ServerViewDetails&serverID=".$insertID;
            
        }
        break;
    case "editserver":
        if ($_POST["hostname"]!="" && $_POST["serverID"]>0)
        {
            $aInfo["hostname"] = htmlspecialchars($_POST["hostname"]);
			$aInfo["iniID"] = $_POST["iniID"];
			$aInfo["mon_startlevel"] = $_POST["mon_startlevel"];
			$aInfo["mon_endlevel"] = $_POST["mon_endlevel"];
			$aInfo["mon_internalreport"] = $_POST["mon_internalreport"];
			$aInfo["mon_externalreport"] = $_POST["mon_externalreport"];
			$aInfo["os_type"] = $_POST["os_type"];
			$aInfo["notes"] = htmlspecialchars($_POST["notes"]);
			$aInfo["cat"] = $_POST["cat"];
			
			$BigDaddyControl->SetServer($aInfo, $_POST["serverID"]);
			
            $redirectTo="page=ServerViewDetails&serverID=".$_POST["serverID"];
        }
        break;
    case "enableserver":
        if ($_REQUEST["serverID"]>0)
        {
			$BigDaddyControl->SetServerStatusEnabled($_REQUEST["serverID"]);
            $redirectTo=$_SESSION["sessdata"]["pagefrom"];
        }
        break;
    case "disableserver":
        if ($_REQUEST["serverID"]>0)
        {
			$BigDaddyControl->SetServerStatusDisabled($_REQUEST["serverID"]);
            $redirectTo=$_SESSION["sessdata"]["pagefrom"];
        }
        break;
    case "deleteserver":
        if ($_REQUEST["serverID"]>0)
        {
			
			$BigDaddyControl->RemoveServer($_REQUEST["serverID"]);
            $redirectTo="page=ServerIndex";
        }
        break;
    case "enableall":
        if ($_REQUEST["catID"]>0)
        {
			$BigDaddyControl->SetServerStatusEnabledByCategory($_REQUEST["catID"]);
            $redirectTo=$_SESSION["sessdata"]["pagefrom"];
        }
        break;
    case "disableall":
        if ($_REQUEST["catID"]>0)
        {
			$BigDaddyControl->SetServerStatusDisabledByCategory($_REQUEST["catID"]);
            $redirectTo=$_SESSION["sessdata"]["pagefrom"];
        }
        break;
    case "delayserver":
        if ($_REQUEST["serverID"]>0)
        {
			
			$delayUntil=mktime($_POST["hourselect"],$_POST["minuteselect"], 0, $_POST["monthselect"], $_POST["dayselect"], $_POST["yearselect"]);
			$BigDaddyControl->SetServerStatusDelayed($_REQUEST["serverID"], $delayUntil);
            $redirectTo=$_SESSION["sessdata"]["pagefrom"];
        }
        break;
    case "delayserverall":
        if ($_REQUEST["catID"]>0)
        {
			$delayUntil=mktime($_POST["hourselect"],$_POST["minuteselect"], 0, $_POST["monthselect"], $_POST["dayselect"], $_POST["yearselect"]);
			$BigDaddyControl->SetServerStatusDelayedByCategory($_REQUEST["catID"], $delayUntil);
            $redirectTo=$_SESSION["sessdata"]["pagefrom"];
        }
        break;
    case "resetnormal":
        //Get Server MON INI
		$BigDaddyControl->SetGlobalServerStatusNormal();
        $redirectTo=$_SESSION["sessdata"]["pagefrom"];
        break;
    case "globaldisable":
        //Get Server MON INI
		$BigDaddyControl->SetGlobalServerStatusDisabled();
        $redirectTo=$_SESSION["sessdata"]["pagefrom"];
        break;
    case "globaldelay":
		$delayUntil=mktime($_POST["hourselect"],$_POST["minuteselect"], 0, $_POST["monthselect"], $_POST["dayselect"], $_POST["yearselect"]);
		$BigDaddyControl->SetGlobalServerStatusDelayed($delayUntil);
        $redirectTo=$_SESSION["sessdata"]["pagefrom"];
        break;
}



if ($redirectTo!="")
{
    header("Location: /index.html?".$redirectTo);
    exit;
}
else
{
    header("Location: /index.html");
    exit;
}

?>
